package com.ruoyi.web.controller.laiqianba.source;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.SourcePushResultInfo;
import com.ruoyi.source.service.ISourcePushResultInfoService;
import com.ruoyi.web.wrapper.SourcePushResultInfoWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 线索推送结果Controller
 * 
 * @author ruoyi
 * @date 2023-12-28
 */
@RestController
@RequestMapping("/source/push")
public class SourcePushResultInfoController extends BaseController
{
    @Autowired
    private ISourcePushResultInfoService sourcePushResultInfoService;

    /**
     * 查询线索推送结果列表
     */
    @PreAuthorize("@ss.hasPermi('source:push:list')")
    @GetMapping("/list")
    public TableDataInfo list(SourcePushResultInfo sourcePushResultInfo)
    {
        startPage();
        List<Map<String, Object>> list = sourcePushResultInfoService.selectSourcePushResultInfoMapList(sourcePushResultInfo);
        list = new SourcePushResultInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出线索推送结果列表
     */
    @PreAuthorize("@ss.hasPermi('source:push:export')")
    @Log(title = "线索推送结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SourcePushResultInfo sourcePushResultInfo)
    {
        List<SourcePushResultInfo> list = sourcePushResultInfoService.selectSourcePushResultInfoList(sourcePushResultInfo);
        ExcelUtil<SourcePushResultInfo> util = new ExcelUtil<SourcePushResultInfo>(SourcePushResultInfo.class);
        util.exportExcel(response, list, "线索推送结果数据");
    }

    /**
     * 获取线索推送结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('source:push:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sourcePushResultInfoService.selectSourcePushResultInfoById(id));
    }

    /**
     * 新增线索推送结果
     */
    @PreAuthorize("@ss.hasPermi('source:push:add')")
    @Log(title = "线索推送结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SourcePushResultInfo sourcePushResultInfo)
    {
        return toAjax(sourcePushResultInfoService.insertSourcePushResultInfo(sourcePushResultInfo));
    }

    /**
     * 修改线索推送结果
     */
    @PreAuthorize("@ss.hasPermi('source:push:edit')")
    @Log(title = "线索推送结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SourcePushResultInfo sourcePushResultInfo)
    {
        return toAjax(sourcePushResultInfoService.updateSourcePushResultInfo(sourcePushResultInfo));
    }

    /**
     * 删除线索推送结果
     */
    @PreAuthorize("@ss.hasPermi('source:push:remove')")
    @Log(title = "线索推送结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sourcePushResultInfoService.deleteSourcePushResultInfoByIds(ids));
    }
}
